﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mfChatMessage.aspx.cs" Inherits="msBsc.WebUi.mMall.Seller.mfChatMessage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>手机地接客商城</title>
    <%=getMeta()%>
    <link rel="stylesheet" type="text/css" href="/themes/mStyle1/mGlobal.css" charset="gbk" />
    <link rel="stylesheet" type="text/css" href="/themes/mStyle1/css/home/base.css" charset="gbk" />
    <link href="/themes/mStyle1/css/public/mChatMessage.css" rel="stylesheet" charset="gbk" />
    <%=getBodyBeforeJs()%>
</head>
<body>
    <div class="viewport" style="background: #edeeee;">
        <input type="hidden" id="receiveId" />
        <input type="hidden" id="receiveName" />
        <%=msBsc.WebUi.Code.QtHtmlGet.GetWapHeaderMenuHtml(true) %>
        <form action='#' method="post" id="J_EmailForm">
            <ul class="m_chat" id="chat_list">
            </ul>
            <xmp id="svc_list_temp_message" style="display: none">
                {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                <li>
                    <div class="u_head">
                        <img class="ul_img_head" src="{{d.rows[i]["SENDER_PIC"]}}" />
                    </div>
                    <div class="ulc_message">
                        <span class="ulc_messageInfo">{{d.rows[i]["CONTENT_FOR_MESSAGE"]}}</span>
                        <span class="ulc_h_message"></span>
                    </div>
                </li>
                {{#} }}
                 </xmp>
        </form>
        <div class="c_sendeMessage">
            <div class="tc_input">
                <div class="tc_c_message">
                    <textarea class="tc_messageInfo" id="message"></textarea>
                </div>
            </div>
            <div class="tc_btn">
                <input type="button" class="btn" value="发送" onclick="sendMessage()" />
            </div>
        </div>
    </div>
    <!--start JS引用-->
    <script type="text/javascript" src="/jqPlugin/js/jquery-1.8.3.min.js" charset="gbk"></script>
    <script type="text/javascript" src="/jqPlugin/js/jBase.js" charset="gbk"></script>
    <script type="text/javascript" src="/jqPlugin/js/jBPage.js" charset="gbk"></script>
    <script type="text/javascript" src="/themes/Style1/jsQt.js" charset="gbk"></script>
    <script type="text/javascript" src="/jqPlugin/js/laytpl.js" charset="gbk"></script>
    <script type="text/javascript" src="/themes/wStyle1/js/comm/VerifyJs.js" charset="gbk"></script>
    <script type="text/javascript" src="/themes/wStyle1/js/comm/DateInfo.js" charset="gbk"></script>
    <!--end JS引用-->
    <script type="text/javascript">
        (function () {
            var receiveId = GetQueryStr("receiveId");
            $("#receiveId").val(receiveId);
            var receiveName = GetQueryStr("receiveName");
            $("#receiveName").val(receiveName);
            $("#h_title").text("与 " + receiveName + " 聊天中");
            getMessage();
            $.getMessageCount();
        })()

        function showSendMessage(message, h_img) {
            $("#message").val("");
            var sendHtml = "<li><div class='urc_message'><span class='urc_messageInfo'>" + message + "</span><span class='urc_h_message'></span></div><div class='u_head'><img class='ur_img_head' src='" + h_img + "' /></div></li>";
            $('#chat_list').append(sendHtml);
        }

        function showMessage(data) {
            var _html = $('#svc_list_temp_message').html();

            laytpl(_html).render(data, function (render) {
                $('#chat_list').append(render);
            });
        }

        function getMessage() {
            var receiveId = $("#receiveId").val();
            if (IsNull(receiveId)) {
                return;
            }
            var opart = new jsonRow();
            opart.AddCell("receiveId", receiveId);
            opart.AddCell("ACTION", "getMessage");
            ajaxComm(opart);
            setTimeout("getMessage()", 3000);
        }
        function sendMessage() {
            var receiveId = $("#receiveId").val();
            if (IsNull(receiveId)) {
                alert("接收人不能为空");
                return;
            }
            var receiveName = $("#receiveName").val();
            var message = $.trim($("#message").val());
            if (IsNull(message)) {
                return;
            }
            if (message.length > 200) {
                alert("消息内容最大为200个字符")
                return;
            }
            var opart = new jsonRow();
            opart.AddCell("receiveId", receiveId);
            opart.AddCell("receiveName", receiveName);
            opart.AddCell("message", message);
            opart.AddCell("ACTION", "sendMessage");
            ajaxComm(opart);
        }
    </script>
</body>
<%=getBodyAfterJs() %>
</html>
